﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HustQQClient.UI
{
    public partial class ContactInfoBlock : UserControl
    {
        public delegate void EnterEventHandler(string name, string id, string note, Image face);
        public event EnterEventHandler BeginChat;

        /// <summary>
        /// 联系人HQ号
        /// </summary>
        public string ID { get; set; }

        /// <summary>
        /// 联系人图片
        /// </summary>
        public Image FaceImg
        {
            get { return picFace.Image; }
            set { picFace.Image = value; }
        }

        /// <summary>
        /// 联系人昵称
        /// </summary>
        public string Nickname
        {
            get { return labelName.Text; }
            set { labelName.Text = value; }
        }

        /// <summary>
        /// 联系人签名
        /// </summary>
        public string Note
        {
            get { return labelNote.Text; }
            set { labelNote.Text = value; }
        }

        /// <summary>
        /// 联系人状态
        /// </summary>
        private string state;
        public string State
        {
            get { return state; }
            set 
            { 
                state = value; 
                labelState.Text = "[" + state + "]"; 
            }
        }

        public ContactInfoBlock() 
        {
            InitializeComponent();
        }

        #region Click事件
        private void ContactInfoBlock_Click(object sender, EventArgs e)
        {
            if (BeginChat != null)
                BeginChat(Nickname, ID.Trim(), Note, FaceImg);
        }
        private void flowLayoutPanel1_Click(object sender, EventArgs e)
        {
            ContactInfoBlock_Click(this, e);
        }
        private void flowLayoutPanel2_Click(object sender, EventArgs e)
        {
            ContactInfoBlock_Click(this, e);
        }
        private void labelName_Click(object sender, EventArgs e)
        {
            ContactInfoBlock_Click(this, e);
        }
        private void labelNote_Click(object sender, EventArgs e)
        {
            ContactInfoBlock_Click(this, e);
        }
        private void labelState_Click(object sender, EventArgs e)
        {
            ContactInfoBlock_Click(this, e);
        }
        private void picFace_Click(object sender, EventArgs e)
        {
            ContactInfoBlock_Click(this, e);
        }
        private void tableLayoutPanel1_Click(object sender, EventArgs e)
        {
            ContactInfoBlock_Click(this, e);
        }
        #endregion

        #region MouseEnter事件
        private void ContactInfoBlock_MouseEnter(object sender, EventArgs e)
        {
            this.BackColor = Color.FromArgb(255, 255, 255, 128);
        }
        private void flowLayoutPanel1_MouseEnter(object sender, EventArgs e)
        {
            ContactInfoBlock_MouseEnter(this, e);
        }
        private void flowLayoutPanel2_MouseEnter(object sender, EventArgs e)
        {
            ContactInfoBlock_MouseEnter(this, e);
        }
        private void labelName_MouseEnter(object sender, EventArgs e)
        {
            ContactInfoBlock_MouseEnter(this, e);
        }
        private void labelNote_MouseEnter(object sender, EventArgs e)
        {
            ContactInfoBlock_MouseEnter(this, e);
        }
        private void labelState_MouseEnter(object sender, EventArgs e)
        {
            ContactInfoBlock_MouseEnter(this, e);
        }
        private void picFace_MouseEnter(object sender, EventArgs e)
        {
            ContactInfoBlock_MouseEnter(this, e);
        }
        private void tableLayoutPanel1_MouseEnter(object sender, EventArgs e)
        {
            ContactInfoBlock_MouseEnter(this, e);
        }
        #endregion

        #region MouseLeave事件
        private void ContactInfoBlock_MouseLeave(object sender, EventArgs e)
        {
            this.BackColor = Color.FromName("WhiteSmoke");
        }
        private void flowLayoutPanel1_MouseLeave(object sender, EventArgs e)
        {
            ContactInfoBlock_MouseLeave(this, e);
        }
        private void flowLayoutPanel2_MouseLeave(object sender, EventArgs e)
        {
            ContactInfoBlock_MouseLeave(this, e);
        }
        private void labelName_MouseLeave(object sender, EventArgs e)
        {
            ContactInfoBlock_MouseLeave(this, e);
        }
        private void labelNote_MouseLeave(object sender, EventArgs e)
        {
            ContactInfoBlock_MouseLeave(this, e);
        }
        private void labelState_MouseLeave(object sender, EventArgs e)
        {
            ContactInfoBlock_MouseLeave(this, e);
        }
        private void picFace_MouseLeave(object sender, EventArgs e)
        {
            ContactInfoBlock_MouseLeave(this, e);
        }
        private void tableLayoutPanel1_MouseLeave(object sender, EventArgs e)
        {
            ContactInfoBlock_MouseLeave(this, e);
        }
        #endregion
    }
}
